<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
	<head> 
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
            <link rel="stylesheet" type="text/css" href="<?php echo $GLOBALS['base_path']?>public/css/style.css" media="screen" />
            <link rel="shortcut_icon" href="<?php echo $GLOBALS['base_path']?>public/img/icon.ico" />
            <link rel="icon" href="<?php echo $GLOBALS['base_path']?>public/img/icon.png" />
            <title>Foto</title>
            <script type="text/javascript" src="<?php echo $GLOBALS['base_path']?>public/js/fquery.js"></script>
            <script type="text/javascript">
                function init() {
                    
                }

                function reload() {
                    var page = document.getElementById("more").getAttribute("href");
                    document.getElementById("more").setAttribute("href", parseInt(page) + 1);
                    //alert("<?php echo $this->createUrl('');?>");
                    ajaxGet("<?php echo $this->createUrl('');?>home/getAllWall/" + page , function(result) {
                        document.getElementById("wallList").innerHTML = "";
                        document.getElementById("wallList").innerHTML = result;
                    });
                    
                    return false;
                }

            </script>
	</head> 
	<body onload="init()"> 
            <div id="bodyWrapper">
                <?php $this->render('accountbar');?>
                <div class="dummy"></div>
                <?php $this->render('menubar');?>

                <div id="content">
                    <div id="wallContent">
                        <h2>Halaman Rumah</h2>
                        <form id="wallForm" method="POST" action="<?php echo $this->createUrl('home/postwall')?>">
                            <textarea name="wall" cols="30" rows="5"></textarea><br />
                            <input type="submit" value="POST!" />
                        </form>
                        <div id="wallList">
                        <?php foreach($walls as $wall) :?>
                            <div class="myWall">
                                <div class="myWallCommentPhoto"><img src="<?php if($wall->getPoster()->getProfilePicture() != NULL) echo $wall->getPoster()->getProfilePicture()->getUrl();?>" alt="" /></div>
                                <div class="myWallCommentPoster"><a href="<?php echo $this->createUrl('profile/view/' . $wall->getPoster()->id);?>"> <?php echo $wall->getPoster()->fullname;?></a></div>
                                <div class="myWallCommentContent"><?php echo $wall->content?></div>
                                    <?php foreach($wall->getChildWalls() as $w) : ?>
                                    <div class="myWallComment">
                                        <div class="myWallCommentPhoto"><img src="<?php if($w->getPoster()->getProfilePicture() != NULL) echo $w->getPoster()->getProfilePicture()->getUrl();?>" alt="" /></div>
                                        <div class="myWallCommentPoster"><a href="<?php echo $this->createUrl('profile/view/' . $w->getPoster()->id);?>"> <?php echo $w->getPoster()->fullname;?></a></div>
                                        <div class="myWallCommentContent"><?php echo $w->content?></div>
                                    </div>
                                    <?php endforeach;?>
                                <div class="myWallComment">
                                    <form action="<?php echo $this->createUrl('profile/commentwall/' . $wall->id);?>" method="post">
                                        <input class="commentWallText" type="text" name="commentwall" value="Write your comment..." onfocus="this.value=''" onblur="this.value='Write your comment...'" />
                                    </form>
                                </div>
                            </div>
                        <?php endforeach;?>
                        </div>
                        <a onclick="return reload();" id="more" href="2">More</a>
                        <br /><br /><br />
                    </div>
                    <?php if (count($photos) > 0 || count($users) > 0) : ?>
                    <div id="searchResult">
                        <div id="userSearchResult">
                            <h2>Hasil pencarian pengguna</h2>
                            <?php foreach($users as $user) : ?>
                                <div class="userSearchResultContent">
                                    <div>
                                        <a href="<?php echo $this->createUrl('profile/view/' . $user->id)?>">
                                            <img src="<?php if($user->getProfilePicture() != NULL) echo $user->getProfilePicture()->getUrl();?>" alt="" />
                                        </a>
                                    </div>
                                    <div>
                                        <?php echo $user->getProfileLink();?>
                                    </div>
                                </div>
                            <?php endforeach;?>
                        </div>
                        <div id="photoSearchResult">
                            <div class="dummy"></div>
                            <h2>Hasil pencarian foto</h2>
                            <?php foreach($photos as $photo) : ?>
                            <div class="photoThumb">
                                <img src="<?php echo $photo->getUrl();?>" alt="" />
                            </div>
                            <?php endforeach;?>
                        </div>
                    </div>
                    <?php endif;?>
                </div>
				
                <div id="topPhotos"> <!-- displaying top photos -->
					<div class="topPhotosMember">
						<h3>Latest Photo</h3>
						<a href="<?php echo $this->createUrl('photo/detail/' . $top_photos['latest'][0]->id)?>">
							<img src="<?php echo $GLOBALS['base_path'] . PhotoModel::$UPLOAD_DIR . $top_photos['latest'][0]->name?>" alt="" />
						</a>
					</div>

					<div class="topPhotosMember">
						<h3>Most Liked Photo</h3>
						<a href="<?php echo $this->createUrl('photo/detail/' . $top_photos['rating'][0]->id)?>">
							<img src="<?php echo $GLOBALS['base_path'] . PhotoModel::$UPLOAD_DIR . $top_photos['rating'][0]->name?>" alt="" />
						</a>
					</div>

					<div class="topPhotosMember">
						<h3>Most Popular Photo</h3>
						<a href="<?php echo $this->createUrl('photo/detail/' . $top_photos['popular']->id)?>">
							<img src="<?php echo $GLOBALS['base_path'] . PhotoModel::$UPLOAD_DIR . $top_photos['popular']->name?>" alt="" />
						</a>
					</div>
                </div>

				<div class="dummy">
				</div>
            </div>
	</body>

</html>